package com.bwie.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.Brand;
import com.bwie.service.BrandService;
import com.bwie.mapper.BrandMapper;
import com.bwie.utils.Result;
import com.bwie.vo.BrandVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author 陈彤彤
* @description 针对表【t_brand(品牌表)】的数据库操作Service实现
* @createDate 2025-07-22 21:36:53
*/
@Service
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand>
    implements BrandService{

    @Autowired
    BrandMapper brandMapper;

    /**
     * @param brandVo:
     * @return Result
     * @author :陈彤彤
     * @description 品牌分页列表
     * @date 2025/7/19 10:54
     */
    @Override
    public Result brandList(BrandVo brandVo) {
        Page<Brand> brandPage = new Page<>(brandVo.getPageNum(), brandVo.getPageSize());

        Page<Brand> page = brandMapper.brandList(brandPage, brandVo);
        return Result.ok().setData(page);
    }

    /**
     * @param brand:
     * @return Result
     * @author :陈彤彤
     * @description 修改品牌状态
     * @date 2025/7/20 19:39
     */
    @Override
    public Result changeStatus(Brand brand) {
        brandMapper.updateById(brand);
        return Result.ok();
    }

    /**
     * @param brand:
     * @return Result
     * @author :陈彤彤
     * @description 添加品牌信息
     * @date 2025/7/21 9:24
     */
    @Override
    public Result addBrand(Brand brand) {
        brand.setCreateBy("admin");
        brand.setCreateTime(new Date());
        brand.setUpdateBy("admin");
        brand.setUpdateTime(new Date());
        brandMapper.insert(brand);
        return Result.ok();
    }
}




